/*
 * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION!

import { int32, float32 } from "@koalaui/common"
import { KStringPtr, KBoolean, RuntimeType, runtimeType, isResource, isInstanceOf } from "@koalaui/interop"
import { NodeAttach, remember } from "@koalaui/runtime"
import { ComponentBase } from "./ComponentBase"
import { TypeChecker } from "#components"
import { ArkCommonMethodComponent } from "./ArkCommon"
import { ArkTogglePeer } from "./peers/ArkTogglePeer"
import { UseEventsProperties } from "./use_properties"
import { CommonMethod, ContentModifier } from "./ArkCommonInterfaces"
import { ToggleAttribute, ToggleConfiguration, SwitchStyle, ToggleOptions } from "./ArkToggleInterfaces"
import { Callback_Boolean_Void } from "./SyntheticDeclarations"
import { ResourceColor } from "./ArkUnitsInterfaces"
/** @memo:stable */
export class ArkToggleComponent extends ArkCommonMethodComponent {
    getPeer(): ArkTogglePeer {
        return (this.peer as ArkTogglePeer)
    }
    /** @memo */
    public setToggleOptions(options: ToggleOptions): this {
        if (this.checkPriority("setToggleOptions")) {
            const options_casted = options as (ToggleOptions)
            this.getPeer()?.setToggleOptionsAttribute(options_casted)
            return this
        }
        return this
    }
    /** @memo */
    public onChange(value: ((parameter: boolean) => void)): this {
        if (this.checkPriority("onChange")) {
            const value_casted = value as (((parameter: boolean) => void))
            this.getPeer()?.onChangeAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public contentModifier(value: ContentModifier<object>): this {
        if (this.checkPriority("contentModifier")) {
            const value_casted = value as (ContentModifier<object>)
            this.getPeer()?.contentModifierAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public selectedColor(value: ResourceColor): this {
        if (this.checkPriority("selectedColor")) {
            const value_casted = value as (ResourceColor)
            this.getPeer()?.selectedColorAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public switchPointColor(value: ResourceColor): this {
        if (this.checkPriority("switchPointColor")) {
            const value_casted = value as (ResourceColor)
            this.getPeer()?.switchPointColorAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public switchStyle(value: SwitchStyle): this {
        if (this.checkPriority("switchStyle")) {
            const value_casted = value as (SwitchStyle)
            this.getPeer()?.switchStyleAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public _onChangeEvent_isOn(callback: ((parameter: boolean) => void)): void {
        if (this.checkPriority("_onChangeEvent_isOn")) {
            const callback_casted = callback as (((parameter: boolean) => void))
            this.getPeer()?._onChangeEvent_isOnAttribute(callback_casted)
            return
        }
        return
    }
    public applyAttributesFinish(): void {
        // we calls this function outside of class, so need to make it public
        super.applyAttributesFinish()
    }
}

/** @memo */
export function ArkToggle(
  /** @memo */
  style: ((attributes: ArkToggleComponent) => void) | undefined,
  /** @memo */
  content_: (() => void) | undefined,
  options: ToggleOptions
) {
    const receiver = remember(() => {
        return new ArkToggleComponent()
    })
    NodeAttach<ArkTogglePeer>((): ArkTogglePeer => ArkTogglePeer.create(receiver), (_: ArkTogglePeer) => {
        receiver.setToggleOptions(options)
        style?.(receiver)
        content_?.()
        receiver.applyAttributesFinish()
    })
}
